<template>
  <div>
    <keep-alive>
      <router-view
        v-if="$route.meta.keep"
        @runtu="runtu"
        @runto="runto"
      ></router-view>
    </keep-alive>

    <router-view
      v-if="!$route.meta.keep"
      @runtu="runtu"
      @runto="runto"
    ></router-view>

    <!-- 新建进入页面 -->

    <van-action-sheet v-model="showon" title=" ">
      <estab-lish @runtu="runtu"></estab-lish>
    </van-action-sheet>

    <!-- 弹出创建页面 -->
    <van-action-sheet v-model="reveal">
      <par-lists
        @runto="runto"
        :ids="ids"
        v-if="ids"
        @gotfun="gotfun"
      ></par-lists>
    </van-action-sheet>
  </div>
</template>

<script>
//
// js位置

// 弹起组件
import estabLish from "./components/EstabLish.vue";
import parLists from "./components/parLists.vue";
import { getCreatorJsonData } from "./api/creator.js";
import { getPreinsJsonData } from "./api/preins.js";
import { getChitchatJsonData } from "./api/chitchat.js";
export default {
  data() {
    return {
      showon: false,
      lognu: false,
      reveal: false,
      ids: null,
      creator: null,
    };
  },
  methods: {
    runtu(a) {
      this.showon = a;
    },
    runto(a) {
      this.reveal = a.a;
      this.ids = a.itemid;
    },
    gotfun(a) {
      this.reveal = a;
    },
      getPreinsFun() {
      getPreinsJsonData().then((data) => {
        localStorage.setItem("Preins",JSON.stringify(data["lists"]))
      });
    },
      getChitchatFun() {
      getChitchatJsonData().then((data) => {
        localStorage.setItem("Chitchat",JSON.stringify(data["chatlist"]))
      });
    },
    getCreatlistFun() {
      getCreatorJsonData().then((data) => {
        this.creator = data["creatorlist"];
        if (this.creator) {
          // 取出来用JSON.parse（）
          // 写入用JSON.stringify()
          let aa = JSON.stringify(this.creator);
          window.localStorage.setItem("keys", aa);
          // console.log("fristrun", aa);
        }
      });
      localStorage.setItem("collect", "[]");
    },
  },
  components: {
    estabLish,
    parLists,
  },
  created() {
    this.getCreatlistFun();
    this.getPreinsFun();
    this.getChitchatFun();
  },
};

//
</script>

<style lang="scss" >
// css代码区域
</style>